package ru.pb.game.network.engine.client.packets.receivable;

import ru.pb.game.network.engine.client.packets.FromClientToGameServerPacket;
import ru.pb.game.network.engine.client.packets.sendable.opcode_3608_ACK;
import ru.pb.game.objects.model.players.Player;
import ru.pb.game.objects.model.room.Room;
import ru.pb.game.objects.storage.ObjectsStorage;

/**
 * @author DarkSkeleton
 */
public class opcode_3608_REQ extends FromClientToGameServerPacket
{
	private int limit, seeConf, autobalans, killtime, unk;
	private byte[] unk2;

	public opcode_3608_REQ()
	{}

	@Override
	public void readImpl()
	{
		unk = readH(); // постоянно меняитса
		unk2 = readB(33); // 33 тупых байт, которые не изменяются ни как....
		/*
		 * for(int i = 1; i <= unk2.length; i++)
		 * {
		 * _log.info("byte " + (i) + " = " + unk2[i - 1]);
		 * }
		 */

		killtime = readD();
		limit = readC();
		seeConf = readC();
		autobalans = readH();

		/**
		 * _log.info("unk: " + unk); // Хз
		 * _log.info("killtime: " + killtime); // маска Убиств / Время
		 * _log.info("limit: " + limit); // Лимит на вход
		 * _log.info("seeConf: " + seeConf); // Настройки наблюдения
		 * _log.info("autobalans:" + autobalans); // автобаланс
		 **/
	}

	@Override
	public void runImpl()
	{
		Player p = getPlayer();
		if(getPlayer() != null)
		{
			Room r = p.getRoom();
			r.killtime = killtime;
			r.limit = limit;
			r.seeConf = seeConf;
			r.autobalans = autobalans;

			Player member = null;
			for(int objId : p.getRoom().getAllPlayers().toArray())
			{
				member = ObjectsStorage.getInstance().getPlayer(objId);
				member.sendPacket(new opcode_3608_ACK(r));
			}
		}
	}
}